import * as path from 'path';
import { isUrl } from '../util/lang';
import { localJson } from './local-json';
import { remoteJson } from './remote-json';
import { FetchOptions } from '../interface';

export async function readJson(originUrl: string, rootPath: string, options: FetchOptions) {

  if (isUrl(originUrl)) {
    return await remoteJson(originUrl, options);
  }
  
  return await localJson(path.join(rootPath, originUrl));
};
